package com.wang.music.controller;


import com.wang.music.entity.Consumer;
import com.wang.music.service.ConsumerService;
import com.wang.music.vo.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * <p>
 * 前端用户表 前端控制器
 * </p>
 *
 * @author zifan
 * @since 2021-03-10
 */
@RestController
@RequestMapping("/consumer")
public class ConsumerController {

    @Autowired
    private ConsumerService consumerService;

    /**
     * 上传头像
     */
    @PostMapping("/uploadPic")
    public Map<String, Object> uploadPic(@RequestParam("file") MultipartFile pic) {
        return consumerService.uploadPic(pic);
    }

    /**
     * 新增（注册）用户
     */
    @PostMapping("/addConsumer")
    public Map<String,Object> addConsumer(@RequestBody Consumer consumer){
        return consumerService.addConsumer(consumer);
    }

    /**
     * 获取用户
     */
    @PostMapping("/getConsumers")
    public Map<String,Object> getConsumers(String key,@RequestBody PageVO pageVO){
        return consumerService.getConsumers(key,pageVO);
    }

    /**
     * 修改用户
     */
    @PostMapping("/updateConsumer")
    public Map<String,Object> updateConsumer(@RequestBody Consumer consumer){
        return consumerService.updateConsumer(consumer);
    }

    /**
     * 删除用户
     */
    @PostMapping("/delConsumer")
    public Map<String,Object> delConsumer(@RequestBody Consumer consumer){
        return consumerService.delConsumer(consumer);
    }

}

